<template>
	<view class="pages bgc-w p-30">
		<view class="pages-title fc-0 fs-lg">
			提现金额
		</view>
		<view class="withdraw-box flex align-items-center">
			<text class="text">¥</text>
			<input v-model="apply_money" class="input" type="number" :placeholder="'请输入提现金额'" />
		</view>
		<view class="withdraw-tips flex">
			<view class="fs-lg mr-20">
				提现至
			</view>
			<view class="flex-1 pl-30 pr-30">
				<view class="flex">
					<text>微信零钱包</text>
				</view>
				<view class="flex">
					<text class="fc-999">可提现金额:{{maxMoney}}</text>
				</view>
			</view>
		</view>

		<view class="btn-ac" style="margin-top: 60rpx;" @click="onApply">
			立即提现
		</view>

		<view class="btn-info mt-20" @click="$fn.toPages('/pages/commission/withdrawalRecord','redirectTo')">
			提现记录
		</view>
	</view>
</template>

<script>
	import {
		apiGetStaffsEarn,
		apiApply,
		apiApplyLog,
		apiEarnList
	} from '@/api/commission.js'
	export default {
		data() {
			return {
				//提现金额
				apply_money: '',
				maxMoney: '',
			};
		},
		onLoad(opts) {
			this.maxMoney = opts.money
		},
		methods: {
			async onApply() {
				if (!this.apply_money) {
					uni.showToast({
						title: '请输入提现金额',
						icon: 'none'
					})
					return
				}
				if (this.apply_money > (1 * this.maxMoney)) {
					uni.showToast({
						title: '超出可提现金额范围',
						icon: 'none'
					})
					return
				}
				let res = await apiApply({
					apply_money: this.apply_money
				})
				this.maxMoney = this.maxMoney - this.apply_money
				this.apply_money = ''
			}
		}
	}
</script>

<style lang="scss" scoped>
	.pages {
		width: 100vw;
		height: 100vh;

		.btn-info {
			background-color: #FFF;
			color: #999;
			font-size: 28rpx;
		}

		.pages-title {
			line-height: 116rpx;
		}

		.withdraw-box {
			height: 136rpx;
			border-bottom: 1px solid #E5E5E5;

			.text {
				font-size: 64rpx;
				margin-right: 20rpx;
			}

			.input {
				font-size: 64rpx;
			}
		}


		.withdraw-tips {
			padding: 30rpx 30rpx 120rpx;

			.left {
				font-size: 32rpx;
				margin-right: 20rpx;
			}

			.con {
				flex: 1;
				padding: 0 30rpx;
			}

			.avatar {
				border-radius: 50%;
				width: 40rpx;
				height: 40rpx;
				overflow: hidden;

			}

			.icon {
				width: 32rpx;
				height: 32rpx;
			}
		}
	}
</style>